<template>
  <div>
    <el-form label-width="100px" class="demo-ruleForm">
      <el-input-number v-model="ruleForm.abc" :precision="3" :index="0"></el-input-number>
      <el-input-number v-model="ruleForm.ccc" :precision="3" :index="0"></el-input-number>
    </el-form>

    <el-button @click="print_w">123</el-button>
  </div>
</template>
<script>
var linkWatch = {}
export default {
  data() {
    return {
      asd: {
        a: "this.ruleForm.select*this.ruleForm.biao",
        b: "this.ruleForm.select+this.ruleForm.biao"
      },
      linkparam: ["ruleForm.abc", "ruleForm.ccc"],
      ruleForm: {
        biao: "1",
        select: "123213",
        abc: 2,
        ccc: 0
      }
    }
  },
  methods: {
    print_w(f) {
      console.log(this.ruleForm)
      console.log(linkWatch)
    }
  },
  beforeCreate() {
    var linkparam = this.$options.data()["linkparam"]

    if (linkparam.length > 0) {
      for (var key in linkparam) {
        // 解除key的引用
        let tkey = key
        linkWatch[linkparam[tkey]] = function(newVal, oldVal) {
          console.log(newVal) // 这里写侦听处理代码，tKey就是参数名称
          console.log(oldVal)
        }
      }
    }
    console.log(linkWatch)
  },
  watch: linkWatch
}
</script>
